home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 101-125 / 118 / empire / src / source.zoo / cmd_edit.d next >
Text File  |  1987-12-02  |  24KB  |  818 lines

  1. #empire.g
  2. #empfunc.g
  3.  
  4. /*
  5.  * examineCountry - part of cmd_examine
  6.  */
  7.  
  8. proc examineCountry(uint who)void:
  9.     *Country_t c;
  10.     uint i, col;
  11.  
  12.     c := &Country[who];
  13.     writeln(Chout;
  14.         "c_centerRow = ", c*.c_centerRow,
  15.         ", c_centerCol = ", c*.c_centerCol,
  16.         ", c_techLevel = ", c*.c_techLevel,
  17.         ", c_resLevel = ", c*.c_resLevel);
  18.     write(Chout;
  19.       "c_sectorCount = ", c*.c_sectorCount, ", c_money = ", c*.c_money,
  20.       ", c_btu = ", c*.c_btu, ", c_last = ");
  21.     writeDate(c*.c_last);
  22.     writeln(Chout;);
  23.     writeln(Chout;
  24.         ", c_timer = ", c*.c_timer,
  25.         ", c_status = ", c*.c_status - cs_deity,
  26.         ", c_name = ", &c*.c_name[0],
  27.         ", c_password = ", &c*.c_password[0]);
  28.     write(Chout; "c_realms: ");
  29.     for i from 0 upto REALM_MAX - 1 do
  30.     write(Chout; i, " = (",
  31.           c*.c_realms[i].r_top,  ':', c*.c_realms[i].r_bottom, ',',
  32.           c*.c_realms[i].r_left, ':', c*.c_realms[i].r_right, ")  ");
  33.     od;
  34.     writeln(Chout;);
  35.     writeln(Chout;
  36.         "c_telegramsNew = ", c*.c_telegramsNew,
  37.         ", c_telegramsTail = ", c*.c_telegramsTail,
  38.         ", c_relations = ");
  39.     for i from 0 upto World.w_currCountries - 1 do
  40.     write(Chout;
  41.           case c*.c_relations[i]
  42.           incase r_neutral:
  43.           'n'
  44.           incase r_allied:
  45.           'a'
  46.           incase r_war:
  47.           'w'
  48.           esac,
  49.           "  "
  50.     );
  51.     od;
  52.     writeln(Chout;);
  53.     write(Chout; "c_fleets: ");
  54.     col := 11;
  55.     for i from 0 upto 26 + 26 - 1 do
  56.     if c*.c_fleets[i] ~= NO_FLEET then
  57.         if col > 73 then
  58.         writeln(Chout;);
  59.         writeln(Chout; "          ");
  60.         col := 11;
  61.         fi;
  62.         write(Chout;
  63.           ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +i)*,
  64.           ':', c*.c_fleets[i], ' ');
  65.     fi;
  66.     od;
  67.     writeln(Chout;);
  68. corp;
  69.  
  70. /*
  71.  * examineSector - part of cmd_examine
  72.  */
  73.  
  74. proc examineSector(int r, c)void:
  75.     Sector_t s;
  76.     ItemType_t it;
  77.  
  78.     readSector(r, c, s);
  79.     write(Chout; "Sector ", r, ',', c, " - ", SectorChar[s.s_type],
  80.       ": lastUpdate = ");
  81.     writeDate(s.s_lastUpdate);
  82.     writeln(Chout; ", owner = ", s.s_owner);
  83.     writeln(Chout;
  84.         "iron = ", s.s_iron, ", gold = ", s.s_gold,
  85.         ", checkPoint = ", s.s_checkPoint,
  86.         ", type = ", SectorChar[s.s_type],
  87.         ", shipCount = ", s.s_shipCount);
  88.     writeln(Chout;
  89.         "production = ", s.s_production,
  90.         ", mobility = ", s.s_mobility,
  91.         ", efficiency = ", s.s_efficiency);
  92.     writeln(Chout;
  93.         "plagueStage = ", s.s_plagueStage,
  94.         ", plagueTime = ", s.s_plagueTime,
  95.         ", defender = ", s.s_defender : x : -2,
  96.         ", price = ", s.s_price);
  97.     for it from it_first upto it_last do
  98.     writeln(Chout; getItemName(it), ": quantity ", s.s_quantity[it],
  99.         ", direction ", s.s_direction[it],
  100.         ", threshold ", s.s_threshold[it]);
  101.     od;
  102. corp;
  103.  
  104. /*
  105.  * examineShip - part of cmd_examine
  106.  */
  107.  
  108. proc examineShip(uint shipNumber)void:
  109.     Ship_t ship;
  110.  
  111.     readShip(shipNumber, ship);
  112.     write(Chout; "Ship \#", shipNumber, " (", getShipName(ship.sh_type),
  113.       "): lastUpdate = ");
  114.     writeDate(ship.sh_lastUpdate);
  115.     writeln(Chout; ", owner = ", ship.sh_owner);
  116.     writeln(Chout; "price = ", ship.sh_price,
  117.         ", fleet = ", ship.sh_fleet,
  118.         ", at ", ship.sh_row, ',', ship.sh_col,
  119.         ", effic = ", ship.sh_efficiency,
  120.         ", mobil = ", ship.sh_mobility);
  121.     writeln(Chout; "crew = ", ship.sh_crew,
  122.         ", shells = ", ship.sh_shells,
  123.         ", guns = ", ship.sh_guns,
  124.         ", planes = ", ship.sh_planes,
  125.         ", ore = ", ship.sh_ore,
  126.         ", bars = ", ship.sh_bars);
  127. corp;
  128.  
  129. /*
  130.  * examineFleet - part of cmd_examine.
  131.  */
  132.  
  133. proc examineFleet(uint fleetNumber)void:
  134.     Fleet_t fleet;
  135.     uint i;
  136.  
  137.     readFleet(fleetNumber, fleet);
  138.     if fleet.f_count = 0 then
  139.     writeln(Chout; "No ships in fleet \#", fleetNumber);
  140.     else
  141.     write(Chout; "Ships in fleet \#", fleetNumber, ": ");
  142.     for i from 0 upto fleet.f_count - 1 do
  143.         write(Chout; fleet.f_ship[i]);
  144.         if i ~= fleet.f_count - 1 then
  145.         write(Chout; '/');
  146.         fi;
  147.     od;
  148.     writeln(Chout;);
  149.     fi;
  150. corp;
  151.  
  152. /*
  153.  * examineLoan - part of cmd_examine.
  154.  */
  155.  
  156. proc examineLoan(uint loanNumber)void:
  157.     Loan_t loan;
  158.  
  159.     readLoan(loanNumber, loan);
  160.     writeln("Loan \#", loanNumber, " offered by ",
  161.         &Country[loan.l_loaner].c_name[0], " to ",
  162.         &Country[loan.l_loanee].c_name[0]);
  163.     write("lastPay = ");
  164.     writeDate(loan.l_lastPay);
  165.     write(", dueDate = ");
  166.     writeDate(loan.l_dueDate);
  167.     writeln();
  168.     writeln("amount = ", loan.l_amount, ", paid = ", loan.l_paid,
  169.         ", duration = ", loan.l_duration, ", rate = ", loan.l_rate,
  170.         ", state = ",
  171.         case loan.l_state
  172.         incase l_offered:
  173.         "offered"
  174.         incase l_declined:
  175.         "declined"
  176.         incase l_outstanding:
  177.         "outstanding"
  178.         incase l_paidUp:
  179.         "paid up"
  180.         esac);
  181. corp;
  182.  
  183. /*
  184.  * examineWorld - part of cmd_examine.
  185.  */
  186.  
  187. proc examineWorld()void:
  188.  
  189.     writeln(Chout; "World is ", World.w_rows, " rows by ", World.w_columns,
  190.         " columns, with ", World.w_currCountries, " out of ",
  191.         World.w_maxCountries, " users.");
  192.     writeln(Chout; "Maximum daily connect time = ", World.w_maxConnect / 30,
  193.         " half-hours.");
  194.     writeln(Chout; "Country creation password: ", &World.w_password[0]);
  195.     writeln(Chout; "Next loan: ", World.w_loanNext,
  196.         ", next treaty: ", World.w_treatyNext,
  197.         ", next offer: ", World.w_offerNext,
  198.         ", next ship: ", World.w_shipNext);
  199.     writeln(Chout; "Weather: hiRowInc = ", World.w_hiRowInc,
  200.         ", hiColInc = ", World.w_hiColInc,
  201.         ", loRowInc = ", World.w_loRowInc,
  202.         ", loColInc = ", World.w_loColInc);
  203.     writeln(Chout; "         hiRow = ", World.w_hiRow,
  204.         ", hiCol = ", World.w_hiCol,
  205.         ", loRow = ", World.w_loRow,
  206.         ", loCol = ", World.w_loCol);
  207.     writeln(Chout; "         hiPressure = ", World.w_hiPressure,
  208.         ", loPressure = ", World.w_loPressure);
  209. corp;
  210.  
  211. proc cmd_examine()void:
  212.     uint what, n;
  213.     int r, c;
  214.  
  215.     if ThisCountryNumber = DEITY then
  216.     if reqChoice(&what, "country\esector\eship\efleet\eloan\eworld\e",
  217. "Examine what (country/sector/ship/fleet/loan/world)? ") then
  218.         skipBlanks();
  219.         case what
  220.         incase 0:
  221.         if reqCountry(&n, "Examine which country? ") then
  222.             examineCountry(n);
  223.         fi;
  224.         incase 1:
  225.         if reqSector(&r, &c, "Examine which sector? ") then
  226.             examineSector(r, c);
  227.         fi;
  228.         incase 2:
  229.         if reqShip(&n, "Examine which ship? ") then
  230.             examineShip(n);
  231.         fi;
  232.         incase 3:
  233.         if World.w_fleetNext = 0 then
  234.             err("there are no fleets yet");
  235.         else
  236.             if reqPosRange(&n, World.w_fleetNext - 1,
  237.                    "Examine which fleet? ") then
  238.             examineFleet(n);
  239.             fi;
  240.         fi;
  241.         incase 4:
  242.         if World.w_loanNext = 0 then
  243.             err("there are no loans yet");
  244.         else
  245.             if reqPosRange(&n, World.w_loanNext - 1,
  246.                    "Examine which loan? ") then
  247.             examineLoan(n);
  248.             fi;
  249.         fi;
  250.         incase 5:
  251.         examineWorld();
  252.         esac;
  253.     fi;
  254.     else
  255.     err("only god can examine things");
  256.     fi;
  257. corp;
  258.  
  259. /*
  260.  * repNum - request a replacement for a numeric value.
  261.  */
  262.  
  263. proc repNum(int oldValue, minValue, maxValue; *char prompt)int:
  264.     int n;
  265.     [100] char promptBuffer;
  266.     channel output text promptChannel;
  267.  
  268.     open(promptChannel, &promptBuffer[0]);
  269.     write(promptChannel; prompt, " (", minValue, " - ", maxValue, "): ");
  270.     close(promptChannel);
  271.     writeln(Chout; &promptBuffer[0], oldValue);
  272.     while
  273.     write(Chout; &promptBuffer[0]);
  274.     if readLine(&InputBuffer[0], INPUT_LENGTH) then
  275.         InputPtr := &InputBuffer[0];
  276.         skipBlanks();
  277.         if InputPtr* ~= '\e' then
  278.         if getNumber(&n) then
  279.             if n < minValue then
  280.             err("value too small");
  281.             true
  282.             elif n > maxValue then
  283.             err("value too large");
  284.             true
  285.             else
  286.             false
  287.             fi
  288.         else
  289.             true
  290.         fi
  291.         else
  292.         n := oldValue;
  293.         false
  294.         fi
  295.     else
  296.         n := oldValue;
  297.         pretend(ioerror(Chin), void);
  298.         false
  299.     fi
  300.     do
  301.     od;
  302.     n
  303. corp;
  304.  
  305. /*
  306.  * repScale - replace a scale factor that can be 10 - 1000.
  307.  */
  308.  
  309. proc repScale(*uint pNum; *char prompt)void:
  310.  
  311.     pNum* := repNum(pNum*, 1, 1000, prompt);
  312. corp;
  313.  
  314. /*
  315.  * repMob - replace a mobility - value 0 - 100.
  316.  */
  317.  
  318. proc repMob(*uint pCost; *char name)void:
  319.  
  320.     pCost* := repNum(pCost*, 0, 100, name);
  321. corp;
  322.  
  323. /*
  324.  * repCost - replace a cost - value is 10 - 128.
  325.  */
  326.  
  327. proc repCost(*uint pCost; *char prompt)void:
  328.  
  329.     pCost* := repNum(pCost*, 10, 128, prompt);
  330. corp;
  331.  
  332. /*
  333.  * repRand - replace a base/rand pair.
  334.  */
  335.  
  336. proc repRand(*uint pBase, pRand; *char what)void:
  337.     [50] char buffer;
  338.     channel output text promptChannel;
  339.  
  340.     open(promptChannel, &buffer[0]);
  341.     write(promptChannel; what, " base");
  342.     close(promptChannel);
  343.     pBase* := repNum(pBase*, 0, 127, &buffer[0]);
  344.     open(promptChannel, &buffer[0]);
  345.     write(promptChannel; what, " rand");
  346.     close(promptChannel);
  347.     pRand* := repNum(pRand*, 1, 128, &buffer[0]);
  348. corp;
  349.  
  350. /*
  351.  * editCountry - part of cmd_edit
  352.  */
  353.  
  354. proc editCountry(uint who)void:
  355.     *Country_t c;
  356.  
  357.     c := &Country[who];
  358.     c*.c_status := repNum(c*.c_status - cs_deity, 0, 4, "Status") + cs_deity;
  359.     c*.c_sectorCount := repNum(c*.c_sectorCount, 0, 0x7fff, "Sector count");
  360.     c*.c_techLevel := repNum(c*.c_techLevel, 0, 0x7fff, "Technology level");
  361.     c*.c_resLevel := repNum(c*.c_resLevel, 0, 0x7fff, "Research level");
  362.     c*.c_money := repNum(c*.c_money, 0, 0x7fff, "Money");
  363.     c*.c_btu := repNum(c*.c_btu, 0, BTU_MAX, "BTU's");
  364.     c*.c_timer :=
  365.     repNum(c*.c_timer, 0, World.w_maxConnect, "Remaining play time");
  366.     c*.c_centerRow := repNum(c*.c_centerRow,
  367.     -World.w_rows, World.w_rows - 1, "center row");
  368.     c*.c_centerCol := repNum(c*.c_centerCol,
  369.     -World.w_columns, World.w_columns - 1, "center column");
  370. corp;
  371.  
  372. /*
  373.  * editSector - part of cmd_edit
  374.  */
  375.  
  376. proc editSector(int r, c)void:
  377.     Sector_t s;
  378.     ItemType_t it;
  379.  
  380.     readSector(r, c, s);
  381.     write(Chout; "Sector ", r, ',', c, " - ", SectorChar[s.s_type],
  382.       " lastUpdate = ");
  383.     writeDate(s.s_lastUpdate);
  384.     writeln(Chout;);
  385.     s.s_owner := repNum(s.s_owner, 0, World.w_currCountries, "Owner");
  386.     s.s_iron := repNum(s.s_iron, 0, 127, "Mineral sample");
  387.     s.s_gold := repNum(s.s_gold,0,127,"Gold sample");
  388.     s.s_checkPoint := repNum(s.s_checkPoint, -128, 127, "Checkpoint code");
  389.     s.s_shipCount := repNum(s.s_shipCount, 0, 32767, "Ship count");
  390.     s.s_production := repNum(s.s_production, 0, 127, "Production units");
  391.     s.s_mobility := repNum(s.s_mobility, 0, 127, "Mobility ");
  392.     s.s_efficiency := repNum(s.s_efficiency, 0, 100, "Efficiency");
  393.     s.s_plagueStage := repNum(s.s_plagueStage, 0, 4, "Plague stage");
  394.     s.s_plagueTime := repNum(s.s_plagueTime, 0, 127, "Plague time");
  395.     s.s_price := repNum(s.s_price, 0, 127, "Contract price");
  396.     for it from it_first upto it_last do
  397.     writeQuan(s, it, repNum(readQuan(s, it), 0, 1270, getItemName(it)));
  398.     od;
  399.     writeSector(r, c, s);
  400. corp;
  401.  
  402. /*
  403.  * editShip - part of cmd_edit
  404.  */
  405.  
  406. proc editShip(uint shipNumber)void:
  407.     Ship_t ship;
  408.  
  409.     readShip(shipNumber, ship);
  410.     write(Chout; "Ship \#", shipNumber, " (", getShipName(ship.sh_type),
  411.       " in fleet ", ship.sh_fleet, "): lastUpdate = ");
  412.     writeDate(ship.sh_lastUpdate);
  413.     writeln(Chout;);
  414.     ship.sh_owner :=
  415.     repNum(ship.sh_owner, 0, World.w_currCountries - 1, "Owner");
  416.     ship.sh_price := repNum(ship.sh_price, 0, 127, "Price");
  417.     ship.sh_efficiency := repNum(ship.sh_efficiency, 0, 100, "Efficiency");
  418.     ship.sh_mobility := repNum(ship.sh_mobility, -128, 127, "Mobility");
  419.     ship.sh_row := repNum(ship.sh_row, 0, World.w_rows - 1, "Current row");
  420.     ship.sh_col := repNum(ship.sh_col, 0, World.w_columns - 1, "Current col");
  421.     ship.sh_crew := repNum(ship.sh_crew, 0, 127, "Crew");
  422.     ship.sh_shells := repNum(ship.sh_shells, 0, 127, "Shells");
  423.     ship.sh_guns := repNum(ship.sh_guns, 0, 127, "Guns");
  424.     ship.sh_planes := repNum(ship.sh_planes, 0, 127, "Planes");
  425.     ship.sh_ore := repNum(ship.sh_ore, 0, 127, "Ore");
  426.     ship.sh_bars := repNum(ship.sh_bars, 0, 127, "Bars");
  427.     writeShip(shipNumber, ship);
  428. corp;
  429.  
  430. /*
  431.  * editWorld - part of cmd_edit.
  432.  */
  433.  
  434. proc editWorld()void:
  435.  
  436.     World.w_maxCountries :=
  437.     repNum(World.w_maxCountries, 2, 9, "Maximum \# users");
  438.     World.w_currCountries :=
  439.     repNum(World.w_currCountries, 0, 9, "Current \# users");
  440.     World.w_maxConnect := repNum(World.w_maxConnect / 30, 1, 6,
  441.         "Maximum connect time in half-hours") * 30;
  442.     World.w_loanNext := repNum(World.w_loanNext, 0, 32767, "Next loan");
  443.     World.w_treatyNext := repNum(World.w_treatyNext, 0, 32767, "Next treaty");
  444.     World.w_offerNext := repNum(World.w_offerNext, 0, 32767, "Next offer");
  445.     World.w_shipNext := repNum(World.w_shipNext, 0, 32767, "Next ship");
  446.     World.w_fleetNext := repNum(World.w_fleetNext, 0, 32767, "Next fleet");
  447. corp;
  448.  
  449. /*
  450.  * editWeather - part of cmd_edit.
  451.  */
  452.  
  453. proc editWeather()void:
  454.  
  455.     World.w_hiRowInc := repNum(World.w_hiRowInc, -4, +4, "hiRowInc");
  456.     World.w_hiColInc := repNum(World.w_hiColInc, -4, +4, "hiColInc");
  457.     World.w_loRowInc := repNum(World.w_loRowInc, -4, +4, "loRowInc");
  458.     World.w_loColInc := repNum(World.w_loColInc, -4, +4, "loColInc");
  459.     World.w_hiRow := repNum(World.w_hiRow, 0, World.w_rows * 4 - 1, "hiRow");
  460.     World.w_hiCol := repNum(World.w_hiCol, 0, World.w_columns * 4 - 1,
  461.         "hiCol");
  462.     World.w_loRow := repNum(World.w_loRow, 0, World.w_rows * 4 - 1, "loRow");
  463.     World.w_loCol := repNum(World.w_loCol, 0, World.w_columns * 4 - 1,
  464.         "loCol");
  465.     World.w_hiMin := repNum(World.w_hiMin, 0, 20, "hiMin");
  466.     World.w_hiMax := repNum(World.w_hiMax, 0, 20, "hiMax");
  467.     World.w_loMin := repNum(World.w_loMin, -20, 0, "loMin");
  468.     World.w_loMax := repNum(World.w_loMax, -20, 0, "loMax");
  469.     World.w_hiPressure := repNum(World.w_hiPressure, World.w_hiMin,
  470.         World.w_hiMax, "hiPressure");
  471.     World.w_loPressure := repNum(World.w_loPressure, World.w_loMin,
  472.         World.w_loMax, "loPressure");
  473. corp;
  474.  
  475. /*
  476.  * editProduction - part of cmd_edit.
  477.  */
  478.  
  479. proc editProduction()void:
  480.  
  481.     World.w_resCost := repNum(World.w_resCost, 0, 127, "research cost");
  482.     World.w_techCost := repNum(World.w_techCost, 0, 127, "technology cost");
  483.     World.w_gunCost := repNum(World.w_gunCost, 0, 127, "gun cost");
  484.     World.w_shellCost := repNum(World.w_shellCost, 0, 127, "shell cost");
  485.     World.w_planeCost := repNum(World.w_planeCost, 0, 127, "plane cost");
  486.     World.w_barCost := repNum(World.w_barCost, 0, 127, "bar cost");
  487. corp;
  488.  
  489. /*
  490.  * editMobilities - part of cmd_edit.
  491.  */
  492.  
  493. proc editMobilities()void:
  494.     uint i, j;
  495.     [100] char promptBuffer;
  496.     channel output text promptChannel;
  497.  
  498.     repMob(&World.w_mountMob, "mountMob");
  499.     repMob(&World.w_wildMob, "wildMob");
  500.     repMob(&World.w_defMob, "defMob");
  501.     repMob(&World.w_civMob, "civMob");
  502.     repMob(&World.w_milMob, "milMob");
  503.     repMob(&World.w_shellMob, "shellMob");
  504.     repMob(&World.w_gunMob, "gunMob");
  505.     repMob(&World.w_planeMob, "planeMob");
  506.     repMob(&World.w_oreMob, "oreMob");
  507.     repMob(&World.w_barMob, "barMob");
  508.     for i from 0 upto 3 do
  509.     for j from 0 upto 3 do
  510.         open(promptChannel, &promptBuffer[0]);
  511.         write(promptChannel; "Cost of attack from ",
  512.             case i
  513.             incase 0:
  514.             "highway"
  515.             incase 1:
  516.             "regular"
  517.             incase 2:
  518.             "wilderness"
  519.             incase 3:
  520.             "mountain"
  521.             esac,
  522.             " to ",
  523.             case j
  524.             incase 0:
  525.             "highway"
  526.             incase 1:
  527.             "regular"
  528.             incase 2:
  529.             "wilderness"
  530.             incase 3:
  531.             "mountain"
  532.             esac);
  533.         close(promptChannel);
  534.         World.w_attackMobilityCost[i, j] :=
  535.         repNum(World.w_attackMobilityCost[i, j], 0, 32767,
  536.                &promptBuffer[0]);
  537.     od;
  538.     od;
  539. corp;
  540.  
  541. /*
  542.  * editPlague - part of cmd_edit.
  543.  */
  544.  
  545. proc editPlague()void:
  546.  
  547.     World.w_plagueKiller := repNum(World.w_plagueKiller,
  548.         0, 2270, "plagueKiller");
  549.     repScale(&World.w_plagueBooster, "plagueBooster");
  550.     repRand(&World.w_plagueOneBase,
  551.         &World.w_plagueOneRand, "plague stage one");
  552.     repRand(&World.w_plagueTwoBase,
  553.         &World.w_plagueTwoRand, "plague stage two");
  554.     repRand(&World.w_plagueThreeBase, &World.w_plagueThreeRand,
  555.         "plague stage three");
  556. corp;
  557.  
  558. /*
  559.  * editCosts - edit various costs. (part of cmd_edit)
  560.  */
  561.  
  562. proc editCosts()void:
  563.  
  564.     World.w_efficCost := repNum(World.w_efficCost, 0, 1000, "efficCost");
  565.     World.w_milSuppliesCost := repNum(World.w_milSuppliesCost,
  566.         0, 800, "milSuppliesCost");
  567.     World.w_utilityRate := repNum(World.w_utilityRate, 0, 100, "utilityRate");
  568.     World.w_interestRate :=
  569.         repNum(World.w_interestRate, 0, 200, "interestRate");
  570.     World.w_bridgeCost := repNum(World.w_bridgeCost, 0, 32767, "bridge cost");
  571.     World.w_shipCostMult :=
  572.         repNum(World.w_shipCostMult, 0, 100, "shipCostMult");
  573. corp;
  574.  
  575. /*
  576.  * editScales - part of cmd_edit.
  577.  */
  578.  
  579. proc editScales()void:
  580.  
  581.     repScale(&World.w_resScale, "resScale");
  582.     repScale(&World.w_techScale, "techScale");
  583.     repScale(&World.w_defenseScale, "defenseScale");
  584.     repScale(&World.w_shellScale, "shellScale");
  585.     repScale(&World.w_airportScale, "airportScale");
  586.     repScale(&World.w_harborScale, "harborScale");
  587.     repScale(&World.w_bridgeScale, "bridgeScale");
  588.     repScale(&World.w_goldScale, "goldScale");
  589.     repScale(&World.w_ironScale, "ironScale");
  590.     repScale(&World.w_shipWorkScale, "shipWorkScale");
  591. corp;
  592.  
  593. /*
  594.  * editUpdates - part of cmd_edit.
  595.  */
  596.  
  597. proc editUpdates()void:
  598.  
  599.     repScale(&World.w_efficScale, "efficScale");
  600.     repScale(&World.w_mobilScale, "mobilScale");
  601.     repScale(&World.w_urbanGrowthFactor, "urbanGrowthFactor");
  602.     World.w_bridgeDieFactor := repNum(World.w_bridgeDieFactor,
  603.         10, 4000, "bridgeDieFactor");
  604.     World.w_highGrowthFactor := repNum(World.w_highGrowthFactor,
  605.         10, 2000, "highGrowthFactor");
  606.     World.w_lowGrowthFactor := repNum(World.w_lowGrowthFactor,
  607.         10, 4000, "lowGrowthFactor");
  608.     World.w_BTUDivisor := repNum(World.w_BTUDivisor,
  609.         500, 32767, "BTUDivisor");
  610.     World.w_resDecreaser := repNum(World.w_resDecreaser,
  611.         480, 32767, "resDecreaser");
  612.     World.w_techDecreaser := repNum(World.w_techDecreaser,
  613.         480, 32767, "techDecreaser");
  614.     repRand(&World.w_hurricaneLandBase, &World.w_hurricaneLandRand,
  615.         "hurricane land");
  616.     repRand(&World.w_hurricaneSeaBase, &World.w_hurricaneSeaRand,
  617.         "hurricane sea");
  618. corp;
  619.  
  620. /*
  621.  * editFighting - part of cmd_edit.
  622.  */
  623.  
  624. proc editFighting()void:
  625.  
  626.     World.w_assFortAdv := repNum(World.w_assFortAdv, 1, 10, "assFortAdv");
  627.     World.w_assCapAdv := repNum(World.w_assCapAdv, 1, 10, "assCapAdv");
  628.     World.w_assBankAdv := repNum(World.w_assBankAdv, 1, 10, "assBankAdv");
  629.     World.w_attFortAdv := repNum(World.w_attFortAdv, 1, 10, "attFortAdv");
  630.     World.w_attCapAdv := repNum(World.w_attCapAdv, 1, 10, "attCapAdv");
  631.     World.w_attBankAdv := repNum(World.w_attBankAdv, 1, 10, "attBankAdv");
  632.     World.w_assAdv := repNum(World.w_assAdv, 0, 1000, "assAdv");
  633.     World.w_fortAdv := repNum(World.w_fortAdv, 0, 10, "fortAdv");
  634.     World.w_boardAdv := repNum(World.w_boardAdv, 0, 10000, "boardAdv");
  635. corp;
  636.  
  637. /*
  638.  * editSea - part of cmd_edit.
  639.  */
  640.  
  641. proc editSea()void:
  642.  
  643.     World.w_torpCost := repNum(World.w_torpCost, 0, 10, "torpCost");
  644.     World.w_torpMobCost := repNum(World.w_torpMobCost, 0, 127, "torpMobCost");
  645.     World.w_torpRange := repNum(World.w_torpRange, 0, 25, "torpRange");
  646.     World.w_torpAcc0 := repNum(World.w_torpAcc0, 0, 100, "torpAcc0");
  647.     World.w_torpAcc1 := repNum(World.w_torpAcc1, 0, 100, "torpAcc1");
  648.     World.w_torpAcc2 := repNum(World.w_torpAcc2, 0, 100, "torpAcc2");
  649.     World.w_torpAcc3 := repNum(World.w_torpAcc3, 0, 100, "torpAcc3");
  650.     repRand(&World.w_torpBase, &World.w_torpRand, "torpedo damage");
  651.     World.w_chargeCost := repNum(World.w_chargeCost, 0, 10, "chargeCost");
  652.     World.w_chargeMobCost := repNum(World.w_chargeMobCost, 0, 127,
  653.                    "chargeMobCost");
  654.     repRand(&World.w_chargeBase, &World.w_chargeRand, "depth charge damage");
  655.     repRand(&World.w_mineBase, &World.w_mineRand, "mine damage");
  656. corp;
  657.  
  658. /*
  659.  * editAir - part of cmd_edit.
  660.  */
  661.  
  662. proc editAir()void:
  663.  
  664.     World.w_fuelTankSize := repNum(World.w_fuelTankSize,
  665.         0, 500, "fuelTankSize");
  666.     World.w_fuelRichness := repNum(World.w_fuelRichness,
  667.         0, 400, "fuelRichness");
  668.     World.w_flakFactor := repNum(World.w_flakFactor, 1, 100, "flakFactor");
  669.     repScale(&World.w_landScale, "landScale");
  670.     repRand(&World.w_bombBase, &World.w_bombRand, "bomb damage");
  671.     repRand(&World.w_planeBase, &World.w_planeRand, "crashing plane damage");
  672. corp;
  673.  
  674. /*
  675.  * editMisc - part of cmd_edit.
  676.  */
  677.  
  678. proc editMisc()void:
  679.  
  680.     repScale(&World.w_contractScale, "contractScale");
  681.     World.w_deathFactor := repNum(World.w_deathFactor, 0, 500, "deathFactor");
  682.     World.w_gunMax := repNum(World.w_gunMax, 1, 20, "gunMax");
  683.     repScale(&World.w_rangeDivisor, "rangeDivisor");
  684.     repScale(&World.w_gunScale, "gunScale");
  685.     World.w_lookShipFact := repNum(World.w_lookShipFact,
  686.         10, 32767, "lookShipFact");
  687.     repScale(&World.w_collectScale, "collectScale");
  688.     repScale(&World.w_radarFactor, "radarFactor");
  689.     World.w_spyFactor := repNum(World.w_spyFactor, 1, 1000, "spyFactor");
  690. corp;
  691.  
  692. /*
  693.  * repNaval - replace values in a naval array.
  694.  */
  695.  
  696. proc repNaval(*[range(ShipType_t)] uint pArray; *char what;
  697.           uint minVal, maxVal)void:
  698.     channel output text promptChannel;
  699.     [100] char promptBuffer;
  700.     ShipType_t st;
  701.  
  702.     for st from st_first upto st_last do
  703.     open(promptChannel, &promptBuffer[0]);
  704.     write(promptChannel; what, " of ", getShipName(st));
  705.     close(promptChannel);
  706.     pArray*[st] := repNum(pArray*[st], minVal, maxVal, &promptBuffer[0]);
  707.     od;
  708. corp;
  709.  
  710. /*
  711.  * editNaval - edit ship parameters.
  712.  */
  713.  
  714. proc editNaval()void:
  715.     [50] char buff;
  716.     channel output text promptChannel;
  717.     uint what;
  718.     ItemType_t it;
  719.  
  720.     if reqChoice(&what,
  721.          "cost\esize\elrange\eshrange\ecapacity\espeed\edamage\e",
  722.          "Edit what (cost/size/lrange/shrange/capacity/speed/damage)? "
  723.         ) then
  724.     case what
  725.     incase 0:
  726.         repNaval(&World.w_shipCost, "cost", 0, 128);
  727.     incase 1:
  728.         repNaval(&World.w_shipSize, "size", 0, 1000);
  729.     incase 2:
  730.         repNaval(&World.w_shipRange, "lookout range", 0, 1000);
  731.     incase 3:
  732.         repNaval(&World.w_shipShRange, "shelling range", 0, 1000);
  733.     incase 4:
  734.         for it from it_first upto it_last do
  735.         open(promptChannel, &buff[0]);
  736.         write(promptChannel; getItemName(it), " capacity");
  737.         close(promptChannel);
  738.         repNaval(&World.w_shipCapacity[it], &buff[0], 0, 127);
  739.         od;
  740.     incase 5:
  741.         repNaval(&World.w_shipSpeed, "mobility cost", 0, 10000);
  742.     incase 6:
  743.         repNaval(&World.w_shipDamage, "relative damage", 0, 10);
  744.     esac;
  745.     fi;
  746. corp;
  747.  
  748. proc cmd_edit()void:
  749.     uint what, n;
  750.     int r, c;
  751.  
  752.     if ThisCountryNumber = DEITY then
  753.     if reqChoice(&what,
  754.             "country\e"
  755.             "sector\e"
  756.             "ship\e"
  757.             "world\e"
  758.             "weather\e"
  759.             "production\e"
  760.             "mobilities\e"
  761.             "plague\e"
  762.             "costs\e"
  763.             "scales\e"
  764.             "updates\e"
  765.             "fighting\e"
  766.             "sea\e"
  767.             "air\e"
  768.             "miscellaneous\e"
  769.             "naval\e",
  770.         "Edit what (cou/sec/sh/wo/we/pr/mo/pl/cos/sc/up/fi/sea/ai/mi/na)? "
  771.     ) then
  772.         skipBlanks();
  773.         case what
  774.         incase 0:
  775.         if reqCountry(&n, "Edit which country? ") then
  776.             editCountry(n);
  777.         fi;
  778.         incase 1:
  779.         if reqSector(&r, &c, "Edit which sector? ") then
  780.             editSector(r, c);
  781.         fi;
  782.         incase 2:
  783.         if reqShip(&n, "Edit which ship? ") then
  784.             editShip(n);
  785.         fi;
  786.         incase 3:
  787.         editWorld();
  788.         incase 4:
  789.         editWeather();
  790.         incase 5:
  791.         editProduction();
  792.         incase 6:
  793.         editMobilities();
  794.         incase 7:
  795.         editPlague();
  796.         incase 8:
  797.         editCosts();
  798.         incase 9:
  799.         editScales();
  800.         incase 10:
  801.         editUpdates();
  802.         incase 11:
  803.         editFighting();
  804.         incase 12:
  805.         editSea();
  806.         incase 13:
  807.         editAir();
  808.         incase 14:
  809.         editMisc();
  810.         incase 15:
  811.         editNaval();
  812.         esac;
  813.     fi;
  814.     else
  815.     err("only god can edit things");
  816.     fi;
  817. corp;
  818.